<script setup lang="ts">
const props = defineProps<{ count: number }>();
const emit = defineEmits<{ 'update:count': [count: number] }>();

const count = computed({
  get: () => {
    return props.count;
  },
  set: (value: number) => {
    emit('update:count', value);
  },
});
</script>

<template>
  <div class="counter">
    <button :disabled="count <= 1" @click="count--">
      <SvgIcon name="icon-remove"></SvgIcon>
    </button>
    <input type="text" v-model="count" />
    <button @click="count++">
      <SvgIcon name="icon-add"></SvgIcon>
    </button>
  </div>
</template>

<style lang="scss" scoped>
.counter {
  display: flex;

  button {
    width: 20rem;
    height: 20rem;
    padding: 0;
    border: none;
    border-radius: 4px;
    background-color: var(--border-color);

    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14rem;
  }

  input {
    border: none;
    outline: none;
    width: 40rem;
    height: 18rem;
    line-height: 20rem;
    font-size: 14rem;
    text-align: center;
  }
}
</style>
